package com.cq.hd.member.controller;


import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.member.api.TbBusinessMerchantApi;

import com.cq.hd.member.api.dto.MyMerchantBusinessPageDto;
import com.cq.hd.member.api.dto.UpdateBusinessMerchantOrderDto;
import com.cq.hd.member.api.vo.*;
import com.cq.hd.member.service.TbBusinessMerchantService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商家商户关联表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-21
 */
@RestController
public class TbBusinessMerchantController implements TbBusinessMerchantApi {

    @Autowired
    private TbBusinessMerchantService businessMerchantService;

    @ApiOperation(value = "根据商家id，获取商家自有商户关联数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "businessId", value = "商家id", required = true, paramType = "query", dataType = "Long"),
            @ApiImplicitParam(name = "ownState", value = "是否是商家自有商户：1-否，2-是", required = true, paramType = "query", dataType = "Integer")
    })
    @ApiResponse(response = BusinessMerchantVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<BusinessMerchantVo> getOwnByBusinessId(Long businessId, Integer ownState) {
        return ResultGenerator.success(businessMerchantService.getOwnByBusinessId(businessId, ownState));
    }

    @ApiOperation(value = "我的策划人分页条件列表")
    @ApiResponse(response = MyMerchantBusinessPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<MyMerchantBusinessPageVo>> pageMyBusiness(MyMerchantBusinessPageDto myMerchantBusinessPageDto) {
        return ResultGenerator.success(businessMerchantService.pageMyBusiness(myMerchantBusinessPageDto));
    }

    @ApiOperation(value = "我的策划人列表")
    @ApiResponse(response = MyMerchantBusinessPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<MyMerchantBusinessPageVo>> listMyBusiness(MyMerchantBusinessPageDto myMerchantBusinessPageDto) {
        return ResultGenerator.success(businessMerchantService.listMyBusiness(myMerchantBusinessPageDto));
    }

    @ApiOperation(value = "根据商家id，获取商户数据")
    @ApiResponse(response = MerchantPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<MerchantPageVo>> listMerchantByBusinessId(Long businessId) {
        return ResultGenerator.success(businessMerchantService.listMerchantByBusinessId(businessId));
    }

    @ApiOperation(value = "更新商家与商户相关的统计字段")
    @Override
    public Result<Boolean> updateBusinessMerchantOrder(@RequestBody UpdateBusinessMerchantOrderDto updateBusinessMerchantOrderDto) {
        return ResultGenerator.success(businessMerchantService.updateBusinessMerchantOrder(updateBusinessMerchantOrderDto));
    }

    @ApiOperation(value = "根据商家id批量获取商家自有商户数据数据")
    @Override
    public Result<List<BusinessMerchantVo>> listOwnMerchantByBusinessIds(@RequestBody List<Long> businessIds) {
        return ResultGenerator.success(businessMerchantService.listOwnMerchantByBusinessIds(businessIds));
    }

    @Override
    public Result<List<MasterBusinessVo>> listMasterBusinessByMerchantIds(List<Long> merchantIds) {
        return ResultGenerator.success(businessMerchantService.listMasterBusinessByMerchantIds(merchantIds));
    }
}
